package com.md01.mapper;

import com.md01.entity.Book;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BookMapper {
    @Select("select * from book ")
    List<Book> selectAllBooks();

    @Select("select *from book where bookId=#{id}")
    Book selectBookById(int id);

    @Delete("delete from book where bookId=#{id}")
    int deleteBookById(int id);

    @Insert("insert into book (bookName)values (#{bookName})")
    int insertBook(Book book);

    @Update("update book set bookName=#{bookName}")
    int updateBook(Book book);

    // 根据书名查询图书
    @Select("select *from book where bookName like '%${bookName}%'")
    List<Book> selectBookByBookName(String bookName);

}
